var prefix = api + "/admin/token";

$(function () {
  var deleteFlag = permissions.sys_token_del
  var options = {
    url: prefix + "/page",
    updateUrl: "/pages/sysadm/token/tokenDetail",
    removeUrl: prefix + "/del/{id}",
    modalName: "令牌管理",
    columns: [
      {
        title: "序号",
        formatter: function (value, row, index) {
          return $.table.serialNumber(index);
        }
      },
      {
        field: 'user_info.username',
        title: '用户名',
        formatter: function (value, row, index) {
          return row.user_info.username
        }
      },
      {
        field: 'access_token',
        title: '令牌'
      },
      {
        field: 'token_type',
        title: '类型',
      },
      {
        field: 'expires_in',
        title: '过期时间（秒）'
      },
      {
        title: '操作',
        align: 'center',
        formatter: function (value, row, index) {
          var actions = [];
          actions.push('<a class="btn btn-warning btn-xs" href="javascript:void(0)" onclick="$.operate.view(\'' + row.user_info.username + '\')"><i class="fa fa-search"></i>详细</a>');
          if (deleteFlag) {
            actions.push('<a class="btn btn-danger btn-xs " href="javascript:void(0)" onclick="$.operate.remove(\'' + row.access_token + '\')"><i class="fa fa-remove"></i>删除</a>');
          }
          return actions.join('');
        }
      }]
  };
  $.table.init(options);
});